﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PJ.Data;


namespace PJ.Business
{
    /// <summary>
    /// Entity class
    /// </summary>
    /// <typeparam name="OD">Inner data object</typeparam>
    public abstract class Entity<OD> : BusinessObject<OD>, IEntity
        where OD : IEntityData
    {
        public Entity(OD data)
            : base(data)
        {
        }
        public Entity()
        {
        }
        public virtual string Id
        {
            get
            {

                return ObjectData.Id;
            }
            set
            {
                if (ObjectData.Id != value)
                {
                    ObjectData.Id = value;
                }
            }
        }

        public override void CopyFrom(IBusinessObject data)
        {
            base.CopyFrom(data);
            IEntity idata = data as IEntity;
            if (idata != null)
                this.Id = idata.Id;
        }
    }

}

